package br.ufpe.cin.mouse.pizza.webservice;

import javax.jws.WebMethod;
import javax.jws.WebService;

import br.ufpe.cin.mouse.pizza.Status;
import br.ufpe.cin.mouse.pizza.Util;

import com.google.appengine.api.datastore.Entity;


@WebService
public class WebServicePedido {

	@WebMethod
	public int obtemIdUltimoPedido() {
		
		long maiorId = 0;
		
		//Iterable<Entity> entities = Util.listEntities("Order", null, null);
		Iterable<Entity> entities = Util.listEntities("Order", "status", Status.RECEBIDO.toString());
		
		for (Entity entity : entities) {			
			maiorId = entity.getKey().getId() > maiorId ? entity.getKey().getId() : maiorId;
		}
		
		return (int) maiorId;
		
	}

}
